﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using UIShare;

using EFong.Contract;
using EFong.View.Proxy;

namespace EFong.View.Documentation
{
    public partial class Frm_ReturnInSurancePolicy : BasicForm
    {
        private Contract.InsurancePolicy oldInsurancePolicy = null;
        public Contract.InsurancePolicy NewInsurancePolicy = null;

        private MasterServiceProxy _masterServiceProxy;

        public Frm_ReturnInSurancePolicy(Contract.InsurancePolicy oldInsurancePolicy)
        {
            InitializeComponent();
            this.oldInsurancePolicy = oldInsurancePolicy;
        }

        protected override void LoadDatas()
        {
            this.txt_OldRef.Text = oldInsurancePolicy.Passenger;
        }

        protected override void InitFields()
        {
            this._masterServiceProxy = MasterServiceProxy.GetInstance();
        }

        protected override void Events()
        {
            this.btn_Confirm.Click += (s, e) =>
            {
                var result = _masterServiceProxy.ReturnInsurancePolicy(oldInsurancePolicy, this.txt_NewRef.GetText());
                if (result.IsSuccess) 
                {
                    NewInsurancePolicy = result.ReturnValue;
                    MsgBox.Info("寄回成功");
                    this.Close();
                }
            };

            this.btn_Cancel.Click += (s, e) =>
            {
                this.Close();
            };
        }

        
    }
}
